package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TNlRecord;
import com.ruoyi.business.service.ITNlRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 尿量记录Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/business/nlrecord")
public class TNlRecordController extends BaseController
{
    @Autowired
    private ITNlRecordService tNlRecordService;

    /**
     * 查询尿量记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TNlRecord tNlRecord)
    {
        startPage();
        List<TNlRecord> list = tNlRecordService.selectTNlRecordList(tNlRecord);
        return getDataTable(list);
    }

    /**
     * 导出尿量记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:export')")
    @Log(title = "尿量记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TNlRecord tNlRecord)
    {
        List<TNlRecord> list = tNlRecordService.selectTNlRecordList(tNlRecord);
        ExcelUtil<TNlRecord> util = new ExcelUtil<TNlRecord>(TNlRecord.class);
        util.exportExcel(response, list, "尿量记录数据");
    }

    /**
     * 获取尿量记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tNlRecordService.selectTNlRecordById(id));
    }

    /**
     * 新增尿量记录
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:add')")
    @Log(title = "尿量记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TNlRecord tNlRecord)
    {
        return toAjax(tNlRecordService.insertTNlRecord(tNlRecord));
    }

    /**
     * 修改尿量记录
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:edit')")
    @Log(title = "尿量记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TNlRecord tNlRecord)
    {
        return toAjax(tNlRecordService.updateTNlRecord(tNlRecord));
    }

    /**
     * 删除尿量记录
     */
    @PreAuthorize("@ss.hasPermi('business:nlrecord:remove')")
    @Log(title = "尿量记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tNlRecordService.deleteTNlRecordByIds(ids));
    }
}
